<template>
  <div>
    <!-- 内控总评 -->
    <template>
      <div class="btn-line">
        <a-select
          @change="handleSearch"
          style="width:200px"
          placeholder="请选择"
          v-model="dictId"
          @select="handleAction"
        >
          <a-select-option v-for="item in dict" :key="item.key" :value="item.key">
            {{ item.name }}
          </a-select-option>
        </a-select>
      </div>
      <div class="mt20">
        <a-table
          class="risk-mini-size-table "
          :loading="pagination.loading"
          :columns="dictId==1?dataColumns:dataColumns2"
          :data-source="dictId==1?dataList:dataListAct"
          :pagination="pagination"
          bordered
          @change="pageChange"
          rowKey="id"
          :scroll="{ x: true }"
        >
          <template slot="textOver" slot-scope="text">
            <span class="text-over" :title="text">{{ text }}</span>
          </template>
          <template slot="isFlag" slot-scope="text">
            <span :title="text">{{ text?'是':'否' }}</span>
          </template>
          <template slot="file" slot-scope="text, record" v-if="record">

          </template>
        </a-table>
      </div>
    </template>
  </div>
</template>

<script>
import { getRiskAction, postRiskAction } from '@/api/manage';
import LuckSheetPaste from '@/components/tools/LuckSheetPaste';
import * as api from '@/api/api';
import { CommonMixis } from '@/mixins/CommonMixis';
export default {
  name: 'DataColBy3',
  mixins: [CommonMixis],
  components: {
  },
  data() {
    return {
      dict: [
        { name: '风险点评价', key: 1 },
        { name: '控制活动评价', key: 2 },
      ],
      dictId: 1,
      pagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['10', '30', '50'],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + ' 共' + total + '条';
        },
        total: 0,
        loading: false,
      },
      dataColumns: [
        {
          title: '评价年度',
          dataIndex: 'evaluateYear',
          width: 100,
          align: 'center'
        },
        {
          title: '年度业务部门主动披露风险事件数量',
          width: 100,
          dataIndex: 'exposeNum',
          align: 'center',
        },
        {
          title: '年度监管部门首次披露风险事件数量',
          width: 100,
          dataIndex: 'firstExposeNum',
          align: 'center',
        },
        {
          title: '年度监管部门非首次披露风险事件数量',
          width: 100,
          dataIndex: 'notFirstExposeNum',
          align: 'center',
        },
        {
          title: '风险点风控等级',
          width: 100,
          dataIndex: 'riskLevel',
          align: 'center',
        },

      ],
      dataColumns2: [
        {
          title: '评价年度',
          dataIndex: 'evaluateYear',
          width: 120,
          align: 'center'
        },
        {
          title: '控制活动编号',
          width: 120,
          dataIndex: 'riskActivityNo',
          align: 'center'
        },
        {
          title: '控制活动',
          width: 120,
          dataIndex: 'riskActivity',
          align: 'center',
          scopedSlots: { customRender: 'textOver' }
        },
        {
          title: '业务流程细项是否与实际一致',width: 100,
          dataIndex: 'fitActual',align: 'center',
          customRender:text => {
            if (text ) {
              return '是';
            } else {
              return '否';
            }
          }},
        {title: '业务自评控制活动执行程度是否属实',
          width: 100,
          dataIndex: 'degreeIsTrue',
          align: 'center',
          customRender:text => {
            if (text ) {
              return '是';
            } else {
              return '否';
            }
          }
        },
        {
          title: '控制活动执行程度',
          width: 100,
          dataIndex: 'executeDegree',
          align: 'center',
        },
      ],
      dataList: [],
      dataListAct: [],
      url: {
        getListActivity:'/incEvaluateGeneral/getGeneralActPageInMaxirx',  //活动
        getListRisk:"/incEvaluateGeneral/getGeneralPageInMaxirx" //风险
      },
    };
  },
  mounted() {
    let riskId  = this.$route.query.id
    let companyCode = this.$route.query.companyCode;
    let manageCode = this.$route.query.manageCode;
    let businessModelId = this.$route.query.businessModelId;
    this.$set(this.pagination , 'riskId' , riskId)
    this.$set(this.pagination , 'companyCode' ,companyCode)
    this.$set(this.pagination , 'manageCode' ,manageCode)
    this.$set(this.pagination , 'businessModelId' ,businessModelId)
    this.getInitData();
  },
  methods: {
    handleSearch(){
      this.pagination.current = 1;
      this.getInitData();
    },
    /**
     * 查询列表
     */
    pageChange(page) {
      this.pagination.current = page.current;
      this.pagination.pageSize = page.pageSize;
      this.getInitData();
    },

    handleAction(value){
      if (value == 1){
        this.$set(this.pagination , 'current' , 1)
        this.getInitData()
      }
      if (value == 2){
        this.$set(this.pagination , 'current' , 1)
        this.initData();
      }
    },

    linitData(){
      this.pagination.loading = true;
      getRiskAction(this.url.getListRisk, {
        pageNo: this.pagination.current,
        pageSize: this.pagination.pageSize,
        keyword: this.pagination.keyword,
        type:5 ,
        companyCode: this.pagination.companyCode,
        businessModelId: this.pagination.businessModelId,
        manageCode: this.pagination.manageCode,
        status: this.pagination.status,
        riskId:this.pagination.riskId,
        dataType: this.pagination.dataType,
        isOvertime:this.pagination.isOvertime,
        deptId:this.pagination.deptId,
      }).then(res => {
        const result = res.data;
        if (res.code === 0) {
          this.dataListAct = result.records;
          this.pagination.total = result.total;
        } else {
          this.$message.error('查询列表失败');
        }
      });
      this.pagination.loading = false;
    },
    getInitData() {
      this.pagination.loading = true;
      getRiskAction(this.url.getListRisk, {
        pageNo: this.pagination.current,
        pageSize: this.pagination.pageSize,
        keyword: this.pagination.keyword,
        companyCode: this.pagination.companyCode,
        businessModelId: this.pagination.businessModelId,
        manageCode: this.pagination.manageCode,
        status: this.pagination.status,
        dataType: this.pagination.dataType,
        riskId:this.pagination.riskId,
        isOvertime:this.pagination.isOvertime,
        deptId:this.pagination.deptId,
      }).then(res => {
        const result = res.data;
        if (res.code === 0) {
          this.dataList = result.records;
          this.pagination.total = result.total;
        } else {
          this.$message.error('查询列表失败');
        }
      });
      this.pagination.loading = false;
    },
  }
};
</script>
<style lang="scss" scoped>
@import '../../main.scss';
.mt20{
  margin-top: 20px;
}
</style>
